package cn.genmer.record.controller;

import cn.genmer.record.common.CommonResult;
import cn.genmer.record.model.mongoModel.Fruit;
import cn.genmer.record.model.mongoModel.Place;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("/mongo")
public class MongoController {

    @Autowired
    private MongoTemplate mongoTemplate;


    //新增文档
    @PostMapping(value = "/insert")
    public CommonResult insert(@RequestBody Fruit fruit){
        mongoTemplate.insert(fruit);

        return CommonResult.success();
    }

    //新增文档
    @PostMapping(value = "/save")
    public CommonResult save(@RequestBody Fruit fruit){
        mongoTemplate.save(fruit);

        return CommonResult.success();
    }
}
